// Custom vertexs

#ifndef VERTEX_H
#define VERTEX_H

#include <d3dx10.h>
#include "Vec3.h"
#include "Vec2.h"
#include "Colour.h"

// custom vertex format

//each vertex declaration is an array of D3D10_INPUT_ELEMENT_DESC elements
//Each element in the array describes one component of the vertex

void InitVertexDeclarations();
void DestroyVertexDeclarations();

//===========================VertexPos================================
struct VertexPos
{
	VertexPos():position(0.0f, 0.0f, 0.0f){}
	VertexPos(float x, float y, float z):position(x,y,z){}
	VertexPos(const Vec3& v):position(v){}

	Vec3 position;
};

static D3D10_INPUT_ELEMENT_DESC VertexPosElements[] = 
{
	{"POSITION", 0,  DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA,0}
};	

//===========================VertexCol================================
struct VertexCol
{
	VertexCol():position(0.0f, 0.0f, 0.0f),colour(0.0f,0.0f,0.0f,0.0f){}
	VertexCol(float x, float y, float z, Colour c):position(x,y,z), colour(c){}
	VertexCol(const Vec3& v, Colour c):position(v),colour(c){}

	Vec3 position;
	Colour colour;
};

static D3D10_INPUT_ELEMENT_DESC VertexColElements[] = 
{
	{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA,0},
	{"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0}
};	

//===========================VertexPN================================
struct VertexPN
{
      VertexPN():position(0.0f, 0.0f, 0.0f),normal(0.0f, 0.0f, 0.0f){}
      VertexPN(float x, float y, float z,float nx, float ny, float nz):position(x,y,z), normal(nx,ny,nz){}
      VertexPN(const Vec3& v, const Vec3& n):position(v),normal(n){}

      Vec3 position;
      Vec3 normal;
};

static D3D10_INPUT_ELEMENT_DESC VertexPNElements[] =
{
	{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA,0},
	{"NORMAL", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0}
};

//===========================VertexPNT===============================
struct VertexPNT
{
      VertexPNT():position(0.0f, 0.0f, 0.0f),normal(0.0f, 0.0f, 0.0f),tex0(0.0f, 0.0f){}
      VertexPNT(float x, float y, float z,float nx, float ny, float nz,float u, float v):position(x,y,z), normal(nx,ny,nz), tex0(u,v){}
      VertexPNT(const Vec3& v,const Vec3& n,const Vec2& uv):position(v),normal(n), tex0(uv){}

      Vec3 position;
      Vec3 normal;
      Vec2 tex0;
};

static D3D10_INPUT_ELEMENT_DESC VertexPNTElements[] =
{
	{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA,0},
	{"NORMAL", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0},
	{"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D10_INPUT_PER_VERTEX_DATA, 0}
};

#endif